// wglmesh.hpp
//

#ifndef _WGLMESH_HPP
#define _WGLMESH_HPP

#include "wgl/wglbase.hpp"
#include "wgl/wgl_gltypes.hpp"

#include "glm/vec2.hpp"
#include "glm/vec3.hpp"

namespace wgl
{
  // Vertex
  //
  struct WGL_API Vertex
  {
    glm::vec3 pos;
    glm::vec3 col;
    glm::vec3 norm;
    glm::vec2 uv;
  };



  // Mesh
  //
  class WGL_API Mesh
  {
  public:
    Mesh ();

    GLenum get_polygon_type () { return polygon_type; }
    size_t n_vertices () const { return vertices.size(); }
    size_t n_indices () const { return indices.size(); }
    const Vertex *vertices_data () const { return vertices.data(); }
    const GLuint *indices_data () const { return indices.data(); }
    
    void axis ();
    void cube ();

    void load ( const std::string &path );
    void swap ( GLenum polygon_type,
                std::vector<Vertex> &vertices,
                std::vector<GLuint> &indices );
    void create_normals ( wgl::Mesh &dest,
                          float len=1.f );
    
    void scale ( float sx,
                 float sy,
                 float sz );
    void scale ( float s ) { scale(s, s, s); }

    void uv_scale ( float sx,
                    float sy );
    void uv_scale ( float s ) { uv_scale(s, s); }
    
  private:
    std::vector<Vertex> vertices;
    std::vector<GLuint> indices;
    GLenum polygon_type{};
  };
}

#endif
